package shiqi.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

//将增强织入所有控制器，切面
//@ControllerAdvice
public class globalExceptionHandler {

    @ExceptionHandler(RuntimeException.class) //捕获运行时异常
    @ResponseBody //返回map的Json表示
    public Map<String, String> exceptionHandler() {
        Map<String,String> map = new HashMap<>();
        map.put("error","错误");
        map.put("msg","错误信息");
        return map;
    }
}
